package cn.guet.zuul.filter;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

/**
 * 路由中过滤器
 *
 * @author SAGITTAR
 */
@Component
public class ZuulRouteFilter extends ZuulFilter {

    private static final Logger LOGGER = LogManager.getLogger(ZuulRouteFilter.class);

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        LOGGER.info("route");
        HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
        LOGGER.info(request.getRequestURI());
        return null;
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public String filterType() {
        return "route";
    }
}
